﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace EncryFacade.CLS
{
    class FileWriter
    {
        public void Write(string encrypyStr,string fileNameDesc)
        {
            FileStream fs = null;
            try
            {
                fs = new FileStream(fileNameDesc, FileMode.Create);
                byte[] str = Encoding.Default.GetBytes(encrypyStr);
                fs.Write(str, 0, str.Length);
                fs.Flush();
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine("文件不存在");
                throw;
            }catch(IOException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("文件操作错误");
            }finally
            {
                fs.Close();
            }
        }
    }
}
